package com.tjshop.android;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 所有使用ActionBarActivity的基类，目前MainActivity除外。
 * 
 * @author FIMH
 * @since 2015-01-02
 */
public class AbsBaseActionBarActivity extends SherlockActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// // 显示返回按键
		ActionBar actionBar = getSupportActionBar();
		actionBar.setDisplayShowTitleEnabled(false); // 不显示默认title，使用自定义的title -
														// 可以水平居中
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setDisplayShowHomeEnabled(false);
		// 自定义title
		View v = LayoutInflater.from(this).inflate(
				R.layout.action_bar_title_custom_child, null);
		com.actionbarsherlock.app.ActionBar.LayoutParams params = new com.actionbarsherlock.app.ActionBar.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		actionBar.setCustomView(v, params);

		TextView titleTextView = (TextView) v
				.findViewById(R.id.action_item_title);
		titleTextView.setText(getTitle());
		actionBar.setDisplayShowCustomEnabled(true);

		ImageView r = (ImageView) v.findViewById(R.id.action_item_return);
		r.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}

}
